Date.prototype.Format = function(fmt)   
{ //author: meizz   
  var o = {   
    "M+" : this.getMonth()+1,                 //月份   
    "d+" : this.getDate(),                    //日   
    "h+" : this.getHours(),                   //小时   
    "m+" : this.getMinutes(),                 //分   
    "s+" : this.getSeconds(),                 //秒   
    "q+" : Math.floor((this.getMonth()+3)/3), //季度   
    "S"  : this.getMilliseconds()             //毫秒   
  };   
  if(/(y+)/.test(fmt))   
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
  for(var k in o)   
    if(new RegExp("("+ k +")").test(fmt))   
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
  return fmt;   
}  
function formatDate(str){
  if(str)
  {
      return str.substring(0,10);
  }
}
function getQuery(name){     
   var href = window.location.href;
   var ret = "";
   if(href.indexOf('?')>0)
   {
      var arr = href.replace(/&/g,'?').split('?');
      for(var i=1;i<arr.length;i++)
      {
          var params = arr[i].split('=');
          if(params.length==2)
          {
            if(params[0]==name)
            {             
              ret = params[1];
              break;
            }
          }
          
          
      }
      
   } 
   return ret;
    
}
 
function AddMonth(date, num)
{
    //date为格式化后的日期字符yyyy-MM-dd,num为增加的月份
    var mouthnum = parseInt(num);
    var year = parseInt(date.substring(0, 4));
    var mouth = parseInt(date.substring(5, 7));
    var day = parseInt(date.substring(8, 10));
    if (mouth + mouthnum > 12)
    {
        var newyear = year + 1;
        var newmouth = mouth + mouthnum - 12;
        var newday = day;
    }
    else
    {
        var newyear = year
        var newmouth = mouth + mouthnum;
        var newday = day;
    }
    var newdate = newyear + "-" + newmouth + "-" + newday;
    return newdate;
}
function addDays(days){   
  var d=new Date();
  d.setMilliseconds(d.getMilliseconds()+(days * 24 * 60 * 60 * 1000));
  var month=d.getMonth()+1;   
  var day = d.getDate();
  if(month<10){  
      month = "0"+month;  
  }  
  if(day<10){  
      day = "0"+day;  
  }  
  var val = d.getFullYear()+"-"+month+"-"+day;   
  return val;  
}  
 

